# Contributor: Ben Pye <ben@curlybracket.co.uk>
# Maintainer: Ben Pye <ben@curlybracket.co.uk>
pkgname=libunwind
pkgver=1.4.0
pkgrel=0
pkgdesc="Portable and efficient C programming interface (API) to determine the call-chain of a program"
url="https://www.nongnu.org/libunwind/"
arch="all"
license="MIT"
options="!check" # v1.4.0 12 tests failing - https://github.com/libunwind/libunwind/issues/164
depends_dev="libucontext-dev"
makedepends="$depends_dev autoconf automake libtool linux-headers xz-dev"
subpackages="$pkgname-dbg $pkgname-static $pkgname-dev $pkgname-doc"
source="https://download.savannah.gnu.org/releases/libunwind/libunwind-$pkgver.tar.gz
	force-enable-man.patch
	musl-mips-fix.patch
	ppc64-musl.patch
	fix-ppc64-libdir.patch
	fix-test-coredump-unwind.patch
	fix-libunwind-pc-in.patch
	fix-aarch64-sigset_t.patch
	"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	LDFLAGS="$LDFLAGS -lucontext" CFLAGS="$CFLAGS -fno-stack-protector" \
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-cxx-exceptions
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="60bce1e840f071d3a48cfa8e2acff988977956f659c5c04ce83f00751348fbbeddbfc54e8c9bd6ebc9073423ca5ee1816655dc5aa59fefd0a8edc9c3f7f3b913  libunwind-1.4.0.tar.gz
de3cefd8a2fa9ae3eabf052cb94a1fdde4f9b7e85af839220592269f7a885470572f67ecf6d773129de8d82916fbcbdda44b541f4eeec84744c54f230c36b6a1  force-enable-man.patch
a1751b80f2c42a741f0a7778f758c7afe42653bf61a353edf38182d731008ed7bd0b8a41bf466aa83275b22241bfcd4f6051055489e3cc87fcd7dd4488bc089d  musl-mips-fix.patch
3b59620c758784faa6d66c8a0a2e49ced743b7ebff6a7e461e40aea653ef9f8cbd8948fb766c63acdd625cb506601c102f133074cef9ef150e9bb8b81584fe9d  ppc64-musl.patch
8b66dc1d62e9fd120d136daed743c294d3d586b3da9c527fb65accc3db4fe810e87a176f0a0134c43d913cc33ddfb634039842a289c132a087f3700ee407fe50  fix-ppc64-libdir.patch
7be9e5118f96ea7c344572cb5146f1711cde23eaaf5e72bb17f1fc752d22cf022e56b42747ba8003ec9e141d14cc0c650a7e2a2df3999c66acc4833dbb3df6fc  fix-test-coredump-unwind.patch
68f7e28c6eb6560ebb2e26737913bff9c9f868ec89e2ad0682516e1c78e98698c73d40d6a3765290df2e1280e00c5691f0d8c21cb15263ad8e513f607906ca76  fix-libunwind-pc-in.patch
f9bfd1749610a89065fa530aab1e793064691f0cbd84bd54900df286dd23ece1dfdeb6229624fa5a101809be75d91f380eac3de4edf865bf0adaf77299cc84c1  fix-aarch64-sigset_t.patch"
